<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .phone {
            width: 300px;
            height: 500px;
            border: 2px solid #222;
            margin: 50px auto;
        }

        .slide {
            width: 300px;
            height: 50px;
            border-bottom: 1px solid #000;
            border-top: 1px solid #000;
            border-radius: 25px;
            position: relative;
            margin-top: 350px;
        }

        .circle {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            border: 1px solid red;
            position: absolute;
            top: 0px;
            left: 0;
        }
    </style>
</head>

<body>
    <div class="phone">
        <div class="slide">
            <div class="circle"></div>
        </div>
    </div>
</body>
<script>
    var circle = document.querySelector(".circle");
    var slide = document.querySelector(".slide");
    var phone = document.querySelector(".phone");

    circle.onmousedown = function (event) {
        var event = event || window.event;
        var posX = event.offsetX;

        var maxLeft = phone.clientWidth - circle.clientWidth;
        document.onmousemove = function (event) {
            var event = event || window.event;
            var x = event.pageX - posX - phone.offsetLeft;

            if (x <= 0) x = 0;
            if (x >= maxLeft){
                x = maxLeft;
                location.href = "https://www.baidu.com";
            } 
            circle.style.left = x + "px";
            circle.style.top =  "0px";
        }

        document.onmouseup = function () {
            circle.style.left = "0px";
            document.onmousemove = null;
        }
    }
</script>

</html>